package com.itlaobing.spring.ioc.instantiating;

import org.springframework.beans.factory.FactoryBean;

import java.time.LocalDate;
import java.util.logging.Logger;

public class LocalDateFactoryBean implements FactoryBean<LocalDate> {

    private Logger logger = Logger.getLogger( this.getClass().getName() );

    private int year ;
    private int month ;
    private int date ;

    public LocalDateFactoryBean() {
        super();
        logger.info( "LocalDateFactoryBean()" );
    }

    @Override
    public LocalDate getObject() throws Exception {
        logger.info( "getObject()" );
        LocalDate localDate = LocalDate.of( year , month , date );
        return localDate;
    }

    @Override
    public Class<?> getObjectType() {
        return LocalDate.class;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        logger.info( "setYear(int) : " + year );
        this.year = year;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        logger.info( "setMonth(int) : " + month );
        this.month = month;
    }

    public int getDate() {
        return date;
    }

    public void setDate(int date) {
        logger.info( "setDate(int) : " + date );
        this.date = date;
    }
}
